;;; packages - package definitions for GNU Guix
;;; Copyright (C) 2017 ng0
;;;
;;; This program is free software: you can redistribute it and/or modify
;;; it under the terms of the GNU Affero General Public License as
;;; published by the Free Software Foundation, either version 3 of the
;;; License, or (at your option) any later version.
;;;
;;; This program is distributed in the hope that it will be useful,
;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;;; GNU Affero General Public License for more details.
;;;
;;; You should have received a copy of the GNU Affero General Public License
;;; along with this program.  If not, see <http://www.gnu.org/licenses/>.

(define-module (ng0 packages admin)
  #:use-module (guix packages)
  #:use-module ((guix licenses) #:prefix license:)
  #:use-module (guix git-download)
  #:use-module (guix download)
  #:use-module (guix build-system gnu)
  #:use-module (guix build-system python)
  #:use-module (gnu packages)
  #:use-module (gnu packages admin)
  #:use-module (gnu packages base)
  #:use-module (gnu packages bash)
  #:use-module (gnu packages gawk)
  #:use-module (gnu packages gettext)
  #:use-module (gnu packages ghostscript)
  #:use-module (gnu packages ncurses)
  #:use-module (gnu packages pciutils)
  #:use-module (gnu packages python))

;; Upstream refuses to release, tag, or do anything other than commit.
(define-public inxi
  (let ((commit "8ab19be4e8dba9be7b3589ceded22e9b8a63b37f")
        (revision "1"))
    (package
      (name "inxi")
      (version (string-append "2.3.7" "." revision (string-take commit 7)))
      (source
       (origin
         (method git-fetch)
         (uri (git-reference
               (url "https://github.com/smxi/inxi")
               (commit commit)))
         (snippet '(delete-file "inxi.tar.gz"))
         (file-name (string-append name "-" version "-checkout"))
         (sha256
          (base32
           "1jvccfnwqr30x91yd7aij8vgfqg3sr776ii4v271a5yhk6x8qdrn"))))
      (build-system gnu-build-system)
      (arguments
       `(#:tests? #f
         #:phases
         (modify-phases %standard-phases
           (delete 'configure)
           (delete 'build)
           (replace 'install
             (lambda* (#:key outputs #:allow-other-keys)
               (let* ((out (assoc-ref outputs "out"))
                      (bin (string-append out "/bin"))
                      (man (string-append out "/share/man/man1")))
                 (install-file "inxi" bin)
                 (install-file "inxi.1.gz" man)))))))
      (inputs
       `(("bash" ,bash)
         ("pciutils" ,pciutils)
         ("dfc" ,dfc)
         ;; ("readlink" ,readlink)
         ;; ("stty" ,stty)
         ;; ("tr" ,tr)
         ;; ("uname" ,uname)
         ;; ("wc" ,wc)
         ("grep" ,grep)
         ("psutils" ,psutils)         
         ("gawk" ,gawk)
         ("coreutils" ,coreutils)
         ("findutils" ,findutils)))
      (home-page "http://smxi.org/docs/inxi.htm")
      (synopsis "Full featured system information script")
      (description
       "Inxi is a full rewrite of locsmif's \"infobash\" script.")
      (license license:gpl3+))))

;; Release 0.8 is 4 years old. This is somewhat "0.9beta unreleased".
;; XXX: Needs to be fixed, compare to https://gitweb.gentoo.org/repo/gentoo.git/tree/dev-util/txt2regex/files/txt2regex-0.8-textdomaindir.patch
(define-public txt2regex
  (let ((commit "e7c4067bc964501a585e7b1d87fa57dfeedbb992")
        (revision "1"))
    (package
      (name "txt2regex")
      (version (string-append "0.9-" revision "."
                              (string-take commit 7)))
      (source
       (origin
         (method git-fetch)
         (uri (git-reference
               (url "https://github.com/aureliojargas/txt2regex")
               (commit commit)))
         (file-name (string-append name "-" version "-checkout"))
         (sha256
          (base32
           "0ja5j75a5fv4zq8hcgsvrq22aqsjdvbsrm1z8y3zzrwcm4bhfvlw"))))
      (build-system gnu-build-system)
      (arguments
       `(#:tests? #f
         #:make-flags (list (string-append "DESTDIR="
                                           (assoc-ref %outputs "out")))
         #:phases
         (modify-phases %standard-phases
           (replace 'configure
             (lambda _
               (substitute* "Makefile"
                 (("/usr") ""))
               #t)))))
      (native-inputs
       `(("gettext-minimal" ,gettext-minimal)))
      (home-page "http://aurelio.net/projects/txt2regex/")
      (synopsis "Console Regular Expression Wizard")
      (description
       "Txt2regex is a Regular Expression Wizard that converts human
sentences to regexes.  In a simple interactive console interface, the user
answer questions and the program build the regexes for more than 20
programs, like Vim, Emacs, Perl, PHP, Python, Procmail and OpenOffice.org.
It is a Shell Script 100% written with Bash builtin commands.

Supported programs: AWK, ed, egrep, Emacs, expect, find, gawk, grep, lex,
lisp, mawk, MySQL, OpenOffice.org, Perl, PHP, Postgres, Procmail, Python,
SED, Tcl, VBscript, VI, Vim.")
      (license license:gpl2))))
